import Vue from 'vue'
import 'normalize.css/normalize.css' // A modern alternative to CSS resets
import Element from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import '@/styles/index.scss' // global css
import './app.css'
import App from './App'
import router from './router'
import store from './store'
import i18n from './lang' // Internationalization
import './errorLog' // error log
import './permission' // permission control
import './mock' // simulation data
import {getQueryString} from '@/utils/auth';
import session from '@/libs/storage/session';
import 'xterm/dist/xterm.css'

// 
if(process.env.NODE_ENV === 'test'||process.env.NODE_ENV === 'production'){
	window.loginUrl = 'http://open.teewon.net:9000/openapi-uc/oauth/authorize?client_id=096400fcbe994ba5b210030c16fd4c58&redirect_uri=' + window.location.origin + '/index.html&response_type=code';
}else{
	window.loginUrl = "#/login";
}
// 


import * as filters from './filters' // global filters
// register global utility filters.
Object.keys(filters).forEach(key => {
	Vue.filter(key, filters[key])
})



Vue.use(Element, {
	size: 'medium', // set element-ui default size
	i18n: (key, value) => i18n.t(key, value)
})



Vue.config.productionTip = false;


// start
(function(){
	const code = getQueryString('code');
	if(code) {
		new Vue({
			el: '#app',
			router,
			store,
			i18n,
			render: h => h(App)
		})
	}else {
		if(process.env.NODE_ENV == 'production' || process.env.NODE_ENV == 'test'){
			window.location.href = window.loginUrl
		}else{
			const code = "83fea8ec9fc627f2ebcbe37d7a5fe1fb" ;
			session.set("userInfo", '{"userId":"TWPAAS1200000871455","name":"李智双","role":3,"deptId":"0000000000","deptName":"其他部门","token":"9581b144736f4215951cc786314c4681"}');
			// 本地开发环境
			window.location.href = "http://localhost:5555/?code=" + code ;
			
		}
	}
})();